package groupOne.util;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;


public class RedisUtil {
    
    
    static {
        JedisPoolConfig config = new JedisPoolConfig();
        config.setMaxTotal(100);
        config.setMaxIdle(10);
        config.setMaxWaitMillis(10 * 1000);
        config.setMinIdle(2);
        config.setTestOnCreate(true);
        config.setTestOnBorrow(true);
        config.setTestOnReturn(true);
        
        
        pool = new JedisPool(config, "hadoop162", 6379);
        
    }
    
    private static JedisPool pool;
    
    public static Jedis getRedisClient() {
        Jedis jedis = pool.getResource();
        jedis.select(1);  // 默认选择 1号库
        return jedis;
    }
}
